import { ref } from 'vue'

const isPageLoading = ref(false)

export const usePageLoading = (options?: {
  onLoadStart?: () => void
  onLoadDone?: () => void
}) => {
  const loadStart = () => {
    isPageLoading.value = true
    options?.onLoadStart?.()
  }

  const loadDone = () => {
    isPageLoading.value = false
    options?.onLoadDone?.()
  }

  return {
    isPageLoading,
    loadStart,
    loadDone
  }
}
